﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System.Web.Routing;
using Vit.Common;
using Vit.Common.Providers;
using Vit.Web;
using Vit.Web.Models;
using Vit.Web.Helpers;

namespace Vit.Web.Models
{
    public class WebSite
    {
        public WebSite()
        {
            Users = new List<User>();
            Roles = new List<Role>();
            NavigationGroups = new List<NavigationGroup>();
        }

        [Key]
        [StringLength(50)]
        public string ID { get; set; }

        [StringLength(50)]
        [Required]
        public string Caption { get; set; }

        [StringLength(500)]
        [DataType(DataType.ImageUrl)]
        public string ImageUrl { get; set; }

        [StringLength(500)]
        [DataType(DataType.ImageUrl)]
        public string LogoUrl { get; set; }

        [StringLength(500)]
        [Required]
        [DataType(DataType.Url)]
        public string HomeUrl { get; set; }

        [StringLength(500)]
        [DataType(DataType.MultilineText)]
        public string Description { get; set; }

        [StringLength(500)]
        [DataType(DataType.ImageUrl)]
        public string FavIcon { get; set; }

        [StringLength(20)]
        public string DefaultCharSet { get; set; }

        [StringLength(50)]
        public string DefaultTitle { get; set; }

        [StringLength(500)]
        public string DefaultMetaKeywords { get; set; }

        [StringLength(500)]
        public string DefaultMetaDescription { get; set; }

        [StringLength(500)]
        public string DomainPattern { get; set; }

        public double TimeZone { get; set; }
        [StringLength(50)]
        public string CultureInfo { get; set; }
        [StringLength(50)]
        public string Theme { get; set; }
        [StringLength(50)]
        public string Skin { get; set; }
        [StringLength(50)]
        public string MenuGroup { get; set; }
        [StringLength(200)]
        public string ConfigurationPath { get; set; }

        public virtual ICollection<User> Users { get; set; }
        public virtual ICollection<Role> Roles { get; set; }
        public virtual ICollection<NavigationGroup> NavigationGroups { get; set; }
        public virtual ICollection<WebPage> Pages { get; set; }

        public virtual Portal Portal { get; set; }


        [NotMapped]
        public IEnumerable<FileInfo> ConfigurationFiles
        {
            get
            {
                return PortalHelper.ConfigurationFiles.Where(o => o.FullName.Contains(string.Format("\\Configuration\\{0}\\", this.ConfigurationPath)));
            }
        }
    }
}
